import { showGenericForm, FormConfig } from './baseForm'

export function showEditForm(context: any, existingData: any): Promise<any> {
  const config: FormConfig = {
    title: '✏️ 编辑记录',
    panelTitle: '编辑问题记录',
    viewType: 'editForm',
    debugMessage: '编辑表单启动中...',
    context: {
      filePath: context.filePath,
      lineRange: context.lineRange,
      codeSnippet: context.codeSnippet
    },
    fields: [
      {
        id: 'problem',
        label: '问题描述',
        type: 'textarea',
        required: true,
        value: existingData.problem,
        hint: '支持 Markdown 语法'
      },
      {
        id: 'solution',
        label: '解决方案',
        type: 'textarea',
        required: true,
        value: existingData.solution,
        hint: '支持 Markdown 语法'
      },
      {
        id: 'tags',
        label: '标签',
        type: 'tags',
        placeholder: '输入标签后按回车或逗号分隔',
        required: false,
        value: existingData.tags || [],
        maxTags: 6,
        hint: '最多6个标签，支持中文、英文、数字、下划线、连字符'
      }
    ]
  }

  return showGenericForm(config)
}
